﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PdfLibrary
{
    public static class PdfObjectResolver
    {
        public static object Resolve(object item)
        {
            if (item is PdfIndirectReference)
                item = ((PdfIndirectReference)item).ResolvedObject;

            if (item is PdfDictionary)
            {
                var dict = (PdfDictionary)item;

                var pdfType = PdfDictionaryTypeResolver.Resolve(dict);
                if (pdfType != null)
                    item = DictionaryObjectInterceptor.CreateProxy(pdfType, dict);
            }

            return item;
        }
    }
}
